{template 'common/header'}
<ul class="nav nav-tabs">
	<li  class="active"><a>{if !empty($info['realname'])}{$info['realname']}的客户{else}客户管理{/if}</a></li>
	<li  ><a href="{php echo $this->createWebUrl('xlsupload',array('op'=>''));}">保护客户导入</a></li></a></li>
</ul>
    <div class="main">
		<div class="stat">
		{if $opp=='his'}
			<form action="">
					<input type="hidden" name="act" value="module" />
					<input type="hidden" name="name" value="broke" />
					<input type="hidden" name="do" value="customer" />
					<input type="hidden" name="op" value="mycustomer" />
					<input type="hidden" name="opp" value="his" />
					<input type="hidden" name="cid" value="{$cid}" />
					<table class="table sub-search">
					<table class="table sub-search">
						<tbody>
							<tr>
								<th style="width:100px;">真实姓名</th>
								<td>
									<input name="realname" type="text" value="{$sort['realname']}" />
								</td>
							</tr>
							<tr>
								<th style="width:100px;">手机号码</th>
								<td>
									<input name="mobile" type="text" value="{$sort['mobile']}" />
								</td>
							</tr>
							<tr>
								<th></th>
								<td>
									<input type="submit" name="" value="搜索" class="btn btn-primary">
								</td>
							</tr>
						</tbody>
					</table>
				</form>
		{else}
		{if empty($id)}
			<form action="">
				<input type="hidden" name="act" value="module" />
				<input type="hidden" name="name" value="broke" />
				<input type="hidden" name="do" value="customer" />
				<input type="hidden" name="op" value="sort" />
				<table class="table sub-search">
				<table class="table sub-search">
					<tbody>
						<tr>
							<th style="width:100px;">真实姓名</th>
							<td>
								<input name="realname" type="text" value="{$sort['realname']}" />
							</td>
						</tr>
						<tr>
							<th style="width:100px;">手机号码</th>
							<td>
								<input name="mobile" type="text" value="{$sort['mobile']}" />
							</td>
						</tr>
						<tr>
							<th style="width:100px;">名称</th>
							<td>
								{loop $loupan $l}
								<input type="submit" name="loupan" value="{$l['title']}">
								{/loop}
							</td>
						
						</tr>
						<tr>
							<th></th>
							<td>
								<input type="submit" name="" value="搜索" class="btn btn-primary">
							</td>
						</tr>
					</tbody>
				</table>
			</form>
			{else}
			<form action="">
				<input type="hidden" name="act" value="module" />
				<input type="hidden" name="name" value="broke" />
				<input type="hidden" name="do" value="customer" />
				<input type="hidden" name="op" value="mycustomer" />
				<input type="hidden" name="id" value="{$id}" />
				<table class="table sub-search">
				<table class="table sub-search">
					<tbody>
						<tr>
							<th style="width:100px;">真实姓名</th>
							<td>
								<input name="realname" type="text" value="{$sort['realname']}" />
							</td>
						</tr>
						<tr>
							<th style="width:100px;">手机号码</th>
							<td>
								<input name="mobile" type="text" value="{$sort['mobile']}" />
							</td>
						</tr>
						<tr>
							<th></th>
							<td>
								<input type="submit" name="" value="搜索" class="btn btn-primary">
							</td>
						</tr>
					</tbody>
				</table>
			</form>
			{/if}
			{/if}
			<div class="stat-div">
				<div class="navbar navbar-static-top">
					<div class="navbar-inner">
						<span class="pull-right" style="color:red; padding:10px 10px 0 0;">总数：<?php echo $total;?></span>
						<span class="brand">名单</span>
					</div>
				</div>
				<div class="sub-item" id="table-list">
					<h4 class="sub-title" style="float:right;color:red;"><a href="">刷新</a></h4>
					<h4 class="sub-title">客户名单</h4>

					<form action="" method="post" onsubmit="">
					<div class="sub-content">
						<table class="table table-hover">
							<thead class="navbar-inner">
								<tr>
									{if $opp!='his'}<th class="row-hover"><input type="checkbox" name="selected" onclick="getTop()"/></th>{/if}
									<th class="row-hover">真实姓名</th>
									<th class="row-hover">手机号码</th>
									<th class="row-hover">推荐人</th>
									<th class="row-hover">推荐产品</th>
									<th class="row-hover">推荐时间</th>
									<th class="row-hover">已发放佣金</th>
									<th class="row-hover">提交方式</th>
								    <th class="row-hover">状态</th>
									<th class="row-hover">操作</th>
								</tr>
							</thead>
							<tbody>
								{loop $list $v}
								<tr>
									{if $opp!='his'}
									<td style="text-align: center;">
										{if $v['cid']==0}
											<input type="checkbox" name="select" value="{$v['id']}"/>
										{else}
											已分配
										{/if}
									</td>
									{/if}
									<td style="text-align: center;">
										{$v['realname']}
									</td>
									<td style="text-align: center;">
										{$v['mobile']}
									</td>
									<td style="text-align: center;">
										{$v['tjrrealname']}
									</td>
									<td style="text-align: center;">
										{$loupans[$v['loupan']]}
									</td>
									<td style="text-align: center;">
										{php echo date('Y-m-d',$v['createtime'])}
									</td>
									<td style="text-align: center;">
										{if !empty($commissions[$v['id']])}{$commissions[$v['id']]}{else}0{/if}
									</td>
									<td style="text-align: center;">
									{if $v['flag']==0}
										<span class="label label-important">推荐提交</span>
									{else}
										<span class="label label-success">预约提交</span>
									{/if}
									</td>
									<td style="text-align: center;">
									{if $v['status']==0}
										<span class="label label-important">{$status[$v['status']]}</span>
									{else}
										<span class="label label-success">{$status[$v['status']]}</span>
									{/if}
									</td>
									<td style="text-align: center;">
	
										{if $opp=='his'}
											<a href="{php echo $this->createWebUrl('customer',array('op'=>'del', 'opp'=>'delete', 'id' => $v['id']));}" onclick="return confirm('确定要删除该客户吗？');">删除</a>
											<a href="{php echo $this->createWebUrl('customer',array('op'=>'showdetail', 'opp'=>'showdetail', 'id' => $v['id'], 'cid'=>$info['id']));}">详情</a>	
											<a href="{php echo $this->createWebUrl('customer',array('op'=>'cancel','id' => $v['id']));}" onclick="return confirm('确定从该置业中取消该客户吗？')">取消</a>		
										{else}
											<a href="{php echo $this->createWebUrl('customer',array('op'=>'del','id' => $v['id'], 'mid'=>!empty($info['id'])?$info['id']:$v['mid']));}" onclick="return confirm('确定要删除该客户吗？');">删除</a>
											<a href="{php echo $this->createWebUrl('customer',array('op'=>'showdetail','id' => $v['id'], 'mid'=>!empty($info['id'])?$info['id']:$v['mid']));}">详情</a>	
										{/if}
									</td>
								</tr>
								{/loop}
							</tbody>
						</table>
					</div>
				
					</form>
					{$pager}
				</div>
				{if $opp!='his'}
					<input type="submit" onclick="allot();" value="分配" class="btn btn-primary" style="position:relative;left:25px;"/>
				{/if}
			</div>
		</div>
    </div>

<link type="text/css" rel="stylesheet" href="./resource/style/daterangepicker.css" />
<script type="text/javascript" src="./resource/script/daterangepicker.js"></script>
<script>
$(function() {
	$('#date-range').daterangepicker({
		format: 'YYYY-MM-DD',
		startDate: $(':hidden[name=start]').val(),
		endDate: $(':hidden[name=end]').val(),
		locale: {
			applyLabel: '确定',
			cancelLabel: '取消',
			fromLabel: '从',
			toLabel: '至',
			weekLabel: '周',
			customRangeLabel: '日期范围',
			daysOfWeek: moment()._lang._weekdaysMin.slice(),
			monthNames: moment()._lang._monthsShort.slice(),
			firstDay: 0
		}
	}, function(start, end){
		$('#date-range .date-title').html(start.format('YYYY-MM-DD') + ' 至 ' + end.format('YYYY-MM-DD'));
		$(':hidden[name=start]').val(start.format('YYYY-MM-DD'));
		$(':hidden[name=end]').val(end.format('YYYY-MM-DD'));
	});
	$('#date-range1').daterangepicker({
		format: 'YYYY-MM-DD',
		startDate: $(':hidden[name=start1]').val(),
		endDate: $(':hidden[name=end1]').val(),
		locale: {
			applyLabel: '确定',
			cancelLabel: '取消',
			fromLabel: '从',
			toLabel: '至',
			weekLabel: '周',
			customRangeLabel: '日期范围',
			daysOfWeek: moment()._lang._weekdaysMin.slice(),
			monthNames: moment()._lang._monthsShort.slice(),
			firstDay: 0
		}
	}, function(start, end){
		$('#date-range1 .date-title').html(start.format('YYYY-MM-DD') + ' 至 ' + end.format('YYYY-MM-DD'));
		$(':hidden[name=start1]').val(start.format('YYYY-MM-DD'));
		$(':hidden[name=end1]').val(end.format('YYYY-MM-DD'));
	});

});
	
	function getTop(){
		var xed = document.getElementsByName("selected");
		var x = document.getElementsByName("select");
		
		if(xed[0].checked == true){
			for (var i=0; i<x.length; i++){
				x[i].checked = true;
			}
		}else{
			for (var i=0; i<x.length; i++){
				x[i].checked = false;
			}
		}
	}
	
	function allot(){
		var x = document.getElementsByName("select");
		var flag = false;
		var j = 0;
		
		var selected = new Array();
		for (var i=0; i<x.length; i++){
			if(x[i].checked == true){
				selected[j] = x[i].value;
				flag = true;
				j++;
			}
		}
		if(flag){
			
		}else{
			alert('您还未选择需要分配的人！');
			return;
		}
		
		window.location.href = "{php echo $this->createWebUrl('counselors', array('op'=>'allot'))}&selected="+selected;
	}

</script>
{template 'common/footer'}